package com.qqhf.hitfood.controller;

import com.qqhf.common.entity.AjaxResult;
import com.qqhf.hitfood.service.IOssService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@Api(tags = "O - OSS存储")
@RestController
@RequestMapping("/oss")
public class OssController {
    @Autowired
    private IOssService ossService;

    @Operation(summary = "上传文件")
    @PostMapping("/uploadFile")
    public AjaxResult uploadFile(@RequestBody MultipartFile file,
                                 @RequestParam("type") String type,
                                 @RequestParam("name") String name) {
        String url = ossService.uploadFile(file, type, name);
        return AjaxResult.success(url);
    }
}
